package com.foreknow.service.impl;

import com.foreknow.dao.ConstantItemMapper;
import com.foreknow.dao.ConstantTypeMapper;
import com.foreknow.entity.ConstantType;
import com.foreknow.service.ConstantTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ConstantTypeServiceImpl implements ConstantTypeService {
    @Autowired
    private ConstantTypeMapper constantTypeMapper;
    @Autowired
    private ConstantItemMapper constantItemMapper;
    @Override
    public List<ConstantType> getConstantTypeList(ConstantType record) {
        return constantTypeMapper.getConstantTypeList(record);
    }

    @Override
    public int insert(ConstantType record) {
        return constantTypeMapper.insert(record);
    }

    @Override
    public int delete(Integer id) {
        int i = constantTypeMapper.delete(id);
        if(i==1){
            constantItemMapper.deleteByTypeId(id);
        }
        return i;
    }

    @Override
    public ConstantType selectByPrimaryKey(Integer id) {
        return constantTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(ConstantType record) {
        return constantTypeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<ConstantType> getConstantType() {
        return constantTypeMapper.getConstantType();
    }


}
